﻿declare @roleId UNIQUEIDENTIFIER

set @roleId = '8CE85F6B-902B-46D9-818F-D96A9288ABF4'

select '
if not exists (select 1 from [medianamik_RoleInGroup] where RoleId='''+cast(RoleId as varchar(38))+''' and GroupId='''+cast(GroupId as varchar(38))+''')
begin
INSERT INTO [medianamik_RoleInGroup]
           ([RoleInGroupId]
           ,[RoleId]
           ,[GroupId])
     VALUES
           ('''+cast(RoleInGroupId as varchar(38))+'''
           ,'''+cast([RoleId] as varchar(38))+'''
           ,'''+cast(GroupId as varchar(38))+''')
end'
From [medianamik_RoleInGroup] 
where RoleId = @roleId